package cn.kn.triage.common.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author yinzn
 * @create 2020-10-10 11:14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private int code;
    private String msg;
    private Object data;
    public static R ok (RCode code,Object data){
        return new R(code.getCode(),code.getMsg(),data);
    }
    public static R ok (RCode code){
        return R.ok(code,null);
    }
    public static R ok (Object data){
        return R.ok(RCode.SUCCESS,data);
    }
    public static R ok (){
        return R.ok(RCode.SUCCESS);
    }

    public static R error(RCode code,Object data){
        return new R(code.getCode(),code.getMsg(),data);
    }
    public static R error(RCode code){
        return R.error(code,null);
    }
    public static R error(){
        return R.error(RCode.ERROR);
    }

}
